

var Mock = require('mockjs');
const { Random } = require('mockjs');


/* 加载模板 */
let path = null;


// 全量基金列表
path = './publicFund/publicFundList.js'
// 全量基金推荐列表
path = './publicFund/publicRecommendFundList.js'



var doc = require(path);

/* 生产mock数据 */
var data = Mock.mock(doc)
var jsonString = JSON.stringify(data);

console.log(jsonString);

/* 导出json */
var fs = require('fs');

let pathList = path.split('/');
let fileName = pathList[pathList.length - 1];
let fileNameList = fileName.split(".");
fileName = fileNameList[0];

fs.writeFile(`${fileName}.json`, jsonString, function (err) {
  if (err) {
    return console.log(err);
  }
  console.log("The file was saved!");
});

